/*
 * File:    Variables.c
 * Project:	HobbyPilotFirmware (HPF)
 * Author:  Wouter van Verre
 *
 * Created on February 20, 2011, 3:09 PM
 */

#include "Header.h"

/** Circular Buffers **/
CircularBuffer UART1TXBuffer;
CircularBuffer UART1RXBuffer;

/** Timer related variables **/
uint8 Timer1FirstRun = true;
uint8 Timer4FirstRun = true;

int Timer1Counter = 0;
int Timer4Counter = 0;

/** RadioControl related variables **/
PWMOutChannel ServoOut[NUM_CHAN_OUT];

/** Analog-to-Digital Channels **/
ADChannel XRate;
ADChannel YRate;
ADChannel ZRate;
ADChannel XAccel;
ADChannel YAccel;
ADChannel ZAccel;

int16 ADCSampleCount = 0;

/** Status related variables **/
structCPUStatus CPUStatus;
structDeviceStatus DeviceStatus;

int initCounter = 200;

uint16 cpuLoadCycles = 0;
uint8 cpuLoad = 0;
uint8 cpuLoadMax = 0;
uint16 cpuStackUse = 0;
uint16 cpuStackUseMax = 0;

uint8 GLCompIMUSendSeq = 0;

/** DCM related variables **/
float GyroGain = 0.004261058;
float AccelGain = 0.039517822;

float v3_GyroCorrP[] = {0, 0, 0};
float v3_GyroCorrI[] = {0, 0, 0};

float KpRollPitch = 0.2;
float KiRollPitch = (1 / 64);

float dt = (1 / (float)F_IMU_LOOP);

float m3x3_Rotation[] = { 1, 0, 0,
				  		  0, 1, 0,
				  		  0, 0, 1 };
